package cn.com.lms.business.cc.service;

import cn.com.lms.business.cc.persistence.entity.ExamQuestion;
import cn.com.lms.business.cc.vo.ExamQuestionVO;
import cn.com.lms.business.cc.persistence.repository.CCQuestionDao;
import com.bnzj.core.persistence.BaseService;
import com.bnzj.core.persistence.query.QueryHelpBean;
import org.springframework.stereotype.Service;

@Service
public class CCQuestionService extends BaseService<CCQuestionDao, ExamQuestion, Long> {

    public static QueryHelpBean getQueryHelpBean() {
        String selectSQL = "select eq.*,qc.category_name, " +
                "(select count(1) from bnz_exam_question_subject qs where qs.question_id=eq.id and qs.is_delete=0) as  count," +
                "(select count(1) from bnz_exam_question_subject qs where qs.type=1 and qs.question_id=eq.id and qs.is_delete=0) as  single_count," +
                "(select count(1) from bnz_exam_question_subject qs where qs.type=2 and qs.question_id=eq.id and qs.is_delete=0) as  multiple_count," +
                "(select count(1) from bnz_exam_question_subject qs where qs.type=3 and qs.question_id=eq.id and qs.is_delete=0) as  judge_count," +
                "(select count(1) from bnz_exam_question_subject qs where qs.type=4 and qs.question_id=eq.id and qs.is_delete=0) as  fill_count," +
                "(select count(1) from bnz_exam_question_subject qs where qs.type=5 and qs.question_id=eq.id and qs.is_delete=0) as  explain_count";

        String whereSQL = " from bnz_exam_question as eq left join bnz_exam_question_category as qc on qc.id=eq.category_id where 1=1 ";
        QueryHelpBean queryBean = new QueryHelpBean(selectSQL + whereSQL, "select count(1)" + whereSQL, ExamQuestionVO.class);
        return queryBean;

    }
}
